package com.ipharma.application.services;

import com.ipharma.McdError;
import com.ipharma.config.FormateadorDeFechas;

/**
 * A Batch class.
 * <P>
 * @author JorgE.H
 */
public class Batch
{
  /**
   * Attributes
   */
  protected String expire = "";
  protected int batchId;
  protected int prodId;

  /**
   * Constructor
   * @param pProdId prodcut id 
   * @param pBatchId batch number
   * @param pExpire expiration date
   */
  public Batch( int pProdId, int pBatchId, String pExpire )
  {
    expire	= new String( pExpire );
    batchId = pBatchId;
    prodId  = pProdId;
  }

  /**
   * Returns expiration date
   * @returns String expire date
   */
  public String getExpireDate()
  {
    return expire;
  }

  /**
   * Returns product id
   * @returns int product id
   */
  public int getProductId()
  {
    return prodId;
  }

  /**
   * Returns Batch id
   * @returns int Batch id
   */
  public int getBatchNumber()
  {
    return batchId;
  }

  /**
   * Sets expiration date
   * @param pExpire String date
   */
  public void setExpireDate( String pExpire )
  {
    expire = pExpire;
  }

  /**
   * Sets Batch number
   * @param pBatchId the Batch number
   */
  public void setBatchNumber( int pBatchId )
  {
    batchId = pBatchId;
  }

  /**
   * Sets product id
   * @param pProdId the product id
   */
  public void setProductId( int pProdId )
  {
    prodId = pProdId;
  }

  /**
   * Overrides object method toString
   */
  public String toString()
  {
    try
    {
      return "" + batchId + " - " + FormateadorDeFechas.getDateFormater().format(expire);
    }
    catch ( Exception e )
    {
      McdError.add( e );
    }
    return "" + batchId;
  }

}
